package org.semanticflash.rdf.graph.redirection.provider
{
	import com.bigflexlib.ds.container.zet.IOSet;
	
	import flash.utils.Dictionary;
	
	import org.semanticflash.rdf.graph.redirection.RDFRedirectionContext;
	import org.semanticflash.rdf.triple.IRDFIndexedTripleProvider;
	import org.semanticflash.rdf.triple.RDFTriple;


	public class RDFRedirectedIndexedTripleProvider implements IRDFIndexedTripleProvider
	{
		

		private var provider:IRDFIndexedTripleProvider;
		
		private var context:RDFRedirectionContext;

		private var views:Dictionary = new Dictionary( );
		
		
		
		public function get triples( ):IOSet
		{
			return provider.triples;
		}
		
		
		
		
		public function RDFRedirectedIndexedTripleProvider( provider:IRDFIndexedTripleProvider, context:RDFRedirectionContext )
		{
			this.provider = provider;
			this.context = context;
		}



		public function getTriples( mask:RDFTriple ):IOSet
		{
			return getView( mask ).triples;
		}



		private function getView( mask:RDFTriple ):RDFRedirectedTripleView
		{
			if ( ! views[ mask ] )
			{
				var v:RDFRedirectedTripleView = new RDFRedirectedTripleView( mask, context, provider );
				views[ mask ] = v;
				return v;
			}
			return views[ mask ] as RDFRedirectedTripleView;		
		}


	}

}